﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CubicFWNet.Data.Models;
using CubicFWNet.Data.SystemManager;
using CubicFWNet.Data.ViewModal;

namespace CubicFWNet.Application.SystemManager
{
    public class OriginalCostApp
    {
        private readonly OriginalCostRepository _service = new OriginalCostRepository();
        private readonly OrderProductRepository _serviceOrderProduct = new OrderProductRepository();
        public OriginalCost GetSingleOriginalCost(Guid id)
        {
            return _service.FindEntity(a => a.Id == id);
        }
        public OriginalCost GetSingleOriginalCostByTid(Guid tid)
        {
            return _service.FindEntity(a => a.TechnologytId == tid);
        }

        public int AddOrUpdate(OriginalCost web)
        {
            if (web.Id == Guid.Empty)
            {
                web.Id = Guid.NewGuid();
                return _service.Insert(web);
            }
            else
            {
                return _service.Update(web);
            }
        }

        public IEnumerable<ProductTechnologyView> GetList(int status, string producName, string productNum, string technologyNum)
        {
            return _service.GetList(status, producName, productNum, technologyNum).OrderByDescending(a => a.ApplyTime);
        }
    }
}
